<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Father(uname, age) {
            this.uname = uname;
            this.age = age;
        }
        Father.prototype.money = function() {
            console.log(1000);
        }

        function Son(uname, age, score) {
            this.uname = uname;
            this.age = age;
            this.score = score;
        }

        //不推荐
        // Son.prototype = Father.prototype; //父元素会继承儿子的新方法
        // Son.prototype.exam = function() {
        //     console.log('考试');
        // }

        // var son = new Son('lhd', 15, 80);
        // console.log(son);
        // console.log(Father.prototype);

        // 推荐

        Son.prototype = new Father();
        /*当我们以对象的方式赋值 会覆盖掉原来的属性 */

        Son.prototype.constructor = Son;
        Son.prototype.exam = function() {
            console.log('考试');
        }
        var son = new Son('lhd', 15, 80);
        var father = new Father('father',15,89)
       console.log(son);
        son.money();
        console.log(Son.prototype);
      console.log(father);
    </script>
</body>

</html>